// Ionic Starter App

// angular.module is a global place for creating, registering and retrieving Angular modules
// 'starter' is the name of this angular module example (also set in a <body> attribute in index.html)
// the 2nd parameter is an array of 'requires'
// 'starter.services' is found in services.js
// 'starter.controllers' is found in controllers.js
var app=angular.module('starter', ['ionic', 'starter.controllers', 'starter.services'])

app.run(function($ionicPlatform) {
  $ionicPlatform.ready(function() {
    // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
    // for form inputs)
    if (window.cordova && window.cordova.plugins && window.cordova.plugins.Keyboard) {
      cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
      cordova.plugins.Keyboard.disableScroll(true);

    }
    if (window.StatusBar) {
      // org.apache.cordova.statusbar required
      StatusBar.styleDefault();
    }
  });
})

.config(function($stateProvider, $urlRouterProvider,$ionicConfigProvider) {

  // Ionic uses AngularUI Router which uses the concept of states
  // Learn more here: https://github.com/angular-ui/ui-router
    // Set up the various states which the app can be in.
  // Each state's controller can be found in controllers.js
  $ionicConfigProvider.tabs.style("standard"); // standard | striped

  $ionicConfigProvider.navBar.alignTitle('center');
  $ionicConfigProvider.backButton.text('返回');
  $ionicConfigProvider.tabs.position('bottom');
  $stateProvider

  // setup an abstract state for the tabs directive
  .state('tab', {
    url: '/tab',
    abstract: true,
    templateUrl: 'templates/tabs.html'
  })

  // Each tab has its own nav history stack:

  .state('tab.tab1', {
    url: '/tab1',
    views: {
      'tab1': {
        templateUrl: 'templates/tab1.html',
        controller: 'tab1Ctrl'
      }
    }
  })
   .state('tab.tab1-detail', {
    url: '/tab1/tab1-detail/:id/:title',
    views: {
      'tab1': {
        templateUrl: 'templates/tab1-detail.html',
        controller: 'Tab1DetailCtrl'
      }
    }
  })
  .state('tab.tab2',{
    url:'/tab2',
    views:{
      'tab2':{
        templateUrl:'templates/tab2.html',
        controller:'tab2Ctrl'
      }
    }
  })
  .state('tab.tab2-detail', {
    url: '/tab/tab2-detail/:id/:title',
    views: {
      'tab2': {
        templateUrl: 'templates/tab2-detail.html',
        controller: 'Tab2DetailCtrl'
      }
    }
  })
  .state('tab.tab3', {
    url: '/tab3',
    views: {
      'tab3': {
        templateUrl: 'templates/tab3.html',
        controller: 'tab3Ctrl'
      }
    }
  })

  .state('tab.tablogin', {/*登录注册模板*/
    url: '/tablogin',
    views: {
      'tab3': {
        templateUrl: 'templates/tab-login.html',
        controller: 'TabLoginCtrl'
      }
    }
  })
  .state('tab.tabsc', {/*收藏模板*/
    url: '/tabsc',
    views: {
      'tab3': {
        templateUrl: 'templates/tab-sc.html',
        controller: 'TabScCtrl'
      }
    }
  })
  .state('tab.tabsucess', {/*登录成功*/
    url: '/tabsucess',
    views: {
      'tab3': {
        templateUrl: 'templates/tab-login-details.html',
        controller: 'TabsucessCtrl'
      }
    }
  })
  // if none of the above states are matched, use this as the fallback
  $urlRouterProvider.otherwise('/tab/tab1');

})
  .config(function($stateProvider, $urlRouterProvider,$ionicConfigProvider) {
    $ionicConfigProvider.platform.ios.tabs.style('standard');
    $ionicConfigProvider.platform.ios.tabs.position('bottom');
    $ionicConfigProvider.platform.android.tabs.style('standard');
    $ionicConfigProvider.platform.android.tabs.position('bottom');

    $ionicConfigProvider.platform.ios.navBar.alignTitle('center');
    $ionicConfigProvider.platform.android.navBar.alignTitle('center');

    $ionicConfigProvider.platform.ios.backButton.previousTitleText('返回').icon('ion-ios-arrow-thin-left');
    $ionicConfigProvider.platform.android.backButton.previousTitleText('返回').icon('ion-android-arrow-back');
    $ionicConfigProvider.platform.ios.views.transition('ios');
    $ionicConfigProvider.platform.android.views.transition('android');
  });
